package com.sy.blog.controller;


import com.sy.blog.service.CommentService;
import com.sy.blog.vo.Result;
import com.sy.blog.vo.params.CommentParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.util.Lazy;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("comments")
public class CommentController {

    @Autowired
    private CommentService commentService;

    /**
     * 在文章详情中展示评论列表
     * @return
     */
    @GetMapping("article/{id}")
    public Result listComment(@PathVariable("id") Long id) {
        return commentService.findCommentByArticleId(id);
    }

    /**
     * 用户评论
     * 注意参数是在post请求的请求体中
     * @param commentParams
     * @return
     */
    @PostMapping("create/change")
    public Result doComment(@RequestBody CommentParams commentParams) {
        return commentService.doComment(commentParams);
    }
}
